
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Bc extends CI_Controller {
	     public function __construct()
       {
        parent::__construct();
		$this->load->helper("html");
		$this->load->helper("url");
		$this->load->helper('form');
		$this->load->helper('date');
		$this->load->model("bc_model");
		//$this->load->model("guest_comment_model");
		//$this->load->model("news_events_model");
		//$this->load->model("roomcottages_model");
		$this->load->helper(array('form', 'url'));
		$this->load->database();
	}
	//START ------------------bc---------------------

	function index()
	{
	$data["list_bcs"] = $this->bc_model->get_all_bc();	
	$this->load->view('bc_list_view',$data);
	}
 
	function SearchFromLoads()
	{
		$pick_up_state=$_POST['pick_up_state'];
		$drop_off_state=$_POST['drop_off_state'];
		$data["pick_up_state"]=$pick_up_state;
		$data["drop_off_state"]=$drop_off_state;
		$data["list_bcs"]=$this->bc_model->getbcSearchfromloadsbyFT($_POST['search1'],$pick_up_state,$_POST['search2'],$drop_off_state);
		//$data1["debug"]=$data1["list_bcs"];
		$this->load->view('bc_list_view',$data);
	}
	
function ddlistsort()
	{
	$sort=$_POST['sort'];
	$data["sort"]=$sort;
	//$data["list_at"]=$this->at_model->get_at($search,false);
	$data["list_bcs"]=$this->bc_model->get_bcsort($sort);
	$this->load->view('bc_list_view',$data);
  }
 function SearchBc()
	{
	$column_value=$_POST['column_value'];
	$data["column_value"]=$column_value;
	$data["list_bcs"]=$this->bc_model->getSearchBc($_POST['search_value'],$column_value);
	$this->load->view('bc_list_view',$data);
	}
	
	function view_bc()
	{
		 	    $code = $this->uri->segment(3);
		$data["info"] = $this->bc_model->getbc_info($code);	
		$this->load->view('bc_vw_view',$data);
	}
	function add_bc()
	{
		//$data["driver_bc_data"] = $this->bc_model->add_view_driver_bc();
		$this->load->view('bc_add_view');
	}
	function p_add_bc()
	{
		$this->load->database();			
		$bc_company_name =$_POST['bc_company_name'];
		$bc_n_name =$_POST['bc_n_name'];
		$f_name =$_POST['f_name'];
		$l_name =$_POST['l_name'];
		$address =$_POST['address'];
		$city =$_POST['city'];			
		$state =$_POST['state'];
		$zipcode =$_POST['zipcode'];
		$cell_phone_num =$_POST['cell_phone_num'];
		$alt_phone_num =$_POST['alt_phone_num'];			
		$office_phone_num =$_POST['office_phone_num'];
		$fax_num =$_POST['fax_num'];
		$email_add =$_POST['email_add'];
		$mc_num =$_POST['mc_num'];
		$rep =$_POST['rep'];
		$bc_comment_box =$_POST['bc_comment_box'];
		//		$contract_amt =$_POST['txtcontract_amt'];
		$_sql="insert into bc_profile(profile_type,bc_company_name,bc_n_name,f_name,l_name,address,city,state,zipcode,cell_phone_num,alt_phone_num,office_phone_num,fax_num,email_add,mc_num,rep,bc_comment_box)";
		$_sql.="values('BC','$bc_company_name','$bc_n_name','$f_name','$l_name','$address','$city','$state','$zipcode','$cell_phone_num','$alt_phone_num','$office_phone_num','$fax_num','$email_add','$mc_num','$rep','$bc_comment_box')";
		$query = $this->db->query($_sql); 
	/*	$bc_id=$this->db->insert_id();
		$_sql="insert into bc_contract(bc_id,contract_amount)";
		$_sql.="values($bc_id,$contract_amt)";
		$query = $this->db->query($_sql); */
		$data["list_bcs"] = $this->bc_model->get_all_bc();	
		$this->load->view('bc_list_view',$data);
	}

	function edit_bc()
	{
 	    $code = $this->uri->segment(3);
		$data["info"] = $this->bc_model->getbc_info($code);	
		$this->load->view('bc_edit_view',$data);
	}
	function p_edit_bc()
	{
		$this->load->database();
	    $broker_code= $_POST['hid_broker_code'];
		$bc_company_name =$_POST['bc_company_name'];
		$bc_n_name =$_POST['bc_n_name'];
		$f_name =$_POST['f_name'];
		$l_name =$_POST['l_name'];
		$address =$_POST['address'];
		$city =$_POST['city'];			
		$state =$_POST['state'];
		$zipcode =$_POST['zipcode'];
		$cell_phone_num =$_POST['cell_phone_num'];
		$alt_phone_num =$_POST['alt_phone_num'];			
		$office_phone_num =$_POST['office_phone_num'];
		$fax_num =$_POST['fax_num'];
		$email_add =$_POST['email_add'];
		$mc_num =$_POST['mc_num'];
		$rep =$_POST['rep'];
		$bc_comment_box =$_POST['bc_comment_box'];
		$query = $this->db->query("UPDATE bc_profile SET											  		  	
													  	bc_company_name='$bc_company_name', 
														  	bc_n_name='$bc_n_name',
														  	f_name='$f_name',
														  	l_name='$l_name',
														  	address ='$address',
															city ='$city',			
															state ='$state',
															zipcode ='$zipcode',
														  	cell_phone_num='$cell_phone_num',
														  	alt_phone_num='$alt_phone_num',
														  	office_phone_num='$office_phone_num',
														  	fax_num='$fax_num',
														  	email_add='$email_add',
															mc_num='$mc_num',
															rep='$rep',
															bc_comment_box='$bc_comment_box' where broker_code= $broker_code");
		$data["list_bcs"] = $this->bc_model->get_all_bc();	
		$this->load->view('bc_list_view',$data);		
	}
	function delete_bc()
	{
		$this->load->database();		
		$code = $this->uri->segment(3);
		$query = $this->db->query("delete from bc_profile where broker_code='$code'");
		$data["list_bcs"] = $this->bc_model->get_all_bc();	
		$this->load->view('bc_list_view',$data);
	}
	//END ------------------bc---------------------
	function logout()
	{
		//$this->load->library('session');
		//$this->session->sess_destroy();
		session_start();
		session_destroy();
		//echo $_SESSION['Administrator_log'];
		//unset($_SESSION['Administrator_log']);
		//$data["newsresult"] = $this->bc_model->bc_all_driver_bc();
		$this->load->view('admin_view');
	}

}
?>